#include "AstroMath.h"

void clamp(float* value,float min,float max) {
	assert(max > min);
	if ( *value > max ) {
		*value = max;
	}
	if ( *value < min ) {
		*value = min;
	}
}

void add_clamp(float* value,float add,float max,float min) {
	*value += add;
	if ( *value >= max ) {
		*value = min;
	}
}

void add_clamp(int* value,int add,int max,int min) {
	*value += add;
	if ( *value >= max ) {
		*value = min;
	}
}

float smoothstep(float x) {
	return x * x * ( 3.0f - 2.0f * x);
}

bool outside(float value,float min,float max) {
	bool ret = false;
	if ( value < min || value > max ) {
		ret = true;
	}
	return ret;
}

bool inside(const ds::Vec2& pos,const ds::Rect& rect) {
	float dx = rect.left - pos.x;
	float dy = rect.top - pos.y;
	if ( dx <= 0.0 && dy <= 0.0f ) {
		dx = rect.right - pos.x;
		dy = rect.bottom - pos.y;
		if ( dx >= 0.0 && dy >= 0.0f ) {
			return true;
		}
	}	
	return false;
}

AstroMath::AstroMath(void)
{
}


AstroMath::~AstroMath(void)
{
}
